<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use DB;


class LoginController extends Controller
{    /**

     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        return view('home.login');    

    }
    public function login(Request $request)
    {

    	//$ob = DB::table('user')->get();
    	//$arr = $request->only('email', 'pass');
    		//dd($ob);
    	//dd($request);
   		$email = $request->input('email');
   		$arr = $request->only('lasttime');
		$ob = DB::table('user')->where('email',$email)->first();
		
		if($ob){
			if($request->input('pass') == $ob->pass){
				session(['adminuser'=>$ob]);
				$res = DB::table('user')->where('id',$ob->id)->update($arr);
				return redirect('/');

			}else{
				return redirect('/login')->with('msg',"密码不正确");
			}
		}else{
			return redirect('/login')->with('msg','用户名或密码错误');
		
		
		}
	}

		public function over()
		{
			session()->flush();
			return redirect('/');
		}
    	

    
    

    


   }
 